home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene 96
/
Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso
/
misc
/
coding
/
voxelspc
/
v9.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-30
|
23KB
|
992 lines
/*
#include <disclaimer.h>
There's supposed to be a real long passage here, but I removed it since most
of you prolly dun need to read it. :)
Yeah yeah yeah, my same old saying applies again :
Go on and rip this and be the tortoise of the decade.
Apologies to those 'Braveheart's out there who always have to read the above
line in all my works, but there're simply too many 'DickHead's out there.
Nevermind if you dun dare to flame them, I can do the favor for you :)
It's been a small journey, and a milestone, WaterLogic is 2 yrs old, happy
birthday to ourselves...
Fast 'nuh nuhs' to:
Mode XiX : at least we know who the real lamer is now. See ya on IRC and
: we can continue the joke someday :)
MysTiCal : didn't I tell you?? didn't I tell you??
: if u dun understand the above sentence, ignore it :)
: how's ur leg? back to usual?
BlackMagic : Yes, we'll create a comotion, Cheers to our deal :)
$uperLamers : yeah, we RULE and they SUXX! :)
PowerSurge : i still can't get over your intro, it should've been in TS95 :)
: where have you been?
#iguana : u guys should come to Singapore someday, I'll show you around
: see u the usual time ok?
SDF : keep working on your wormholes :)
Zane : Attitude part #2
: what's synonymous to NeVeR? I know how you hate it, but life's
: like that right? At least I know you'll make great music for
: the demo...hey thanx!
Ng PeiSin : I thought you wanted a MTV for Mystery Hugs?
Morbid : see ya at the other side of the fire lake
: so u joined ArchAngels huh?
EricScorpios: remember to lend me your flame-proof jacket someday :)
TeckShiong : thanx for being my HQ, just one more d/l to DevSite! part 2 :)
NickChan : I'm still waiting for your board to open...
ArchAngels : cool white clothes...who picked the name anyway?
Renegade : *yawn*
Constellation : Hey I see no activity!
AngPetChean : Get a nick and bring a crowd ok?
Pandemonium : dun worry, I'll be your permanent supplier of socks. have fun
: btw, can you -finally- find your vertex normals??
Scavenger : thanx very much for the offer, but i really can't take it now.
Trixter : i'll tell u how to do it alright! quick send it!
: ok, now you know how to do motionblur in less than
: 1ins/pixel, you owe me a nice postcard :)
Jmagic : hey remember the credits ok? :)
: show me ur new engine when it's done!
: btw, 3x3 matrix is not enough, coz I realised this
: Cd=(1-d1/d2)*f/n where 'Cd' is diameter of circle of confusion,
: 'd1' is object distance, 'd2' is image distance, 'f' is
: the focal length. So 'Cd' dictates the size of the matrix :(
PitBull : why r u always buying new PCs?? I'll get a P-180 to beat u!
Sandman : next time I go to London, make sure u r around! :)
Onyx : pmode rules :)
....plus many I forgot....
The magazines who has my demo in their cd-roms, you guys owe me a few copies
of your magazines! Dun forget!
Last words : fi er'uoy doog, s'ereht on deen ot garb
Where do I find this 'Rex Deathstar'??
Try this:
Email : deathstr@singnet.com.sg
BBS : Developer's Site BBS 561-0237
IRC : #coders #waterlogic (DeathScar/DeathStar)
Telepathy is reserved for my close friends :)
Note : Fan mail will be appreciated, but not answered
Foreign distro site is welcomed
Requests to explain my sources will be ignored
Coding discussion is welcomed
Requests to distro on cd-roms need to send 2 copies to me
Questions on 'which book is good etc.' will be ignored
Flames will be used to fry my beef patties
WaterLogic productions
===========================================================================
............................Year 1994......................................
1. REXINTRO.ZIP....debut selftro, very poorly done.
2. ASYLUM!.ZIP ....Advert for Asylum BBS (closed down now :( )
3. ICHIBAN!.ZIP....Advert for IchiBan BBS
4. ANARCHY!.ZIP....Advert for Anarchy Online BBS
5. ICHIBAN2.ZIP....2nd Advert for IchiBan BBS
6. COROM.ZIP ....Advert for COROM PRODUCTIONS BBS
...........................Year 1995.......................................
7. _FACES.ZIP ....Slideshow demo featuring realtime crossfading
8. TINIFIRE.ZIP....76 byte fire routine, real small huh? (Full sources)
9. TINYSTAR.ZIP....123 byte 3D starfield, another small one. (Full sources)
10. DELAYDOT.ZIP....3D object morph with delaydots. (Full sources)
11. PARTICLE.ZIP....3D Lissajous figures morph. (Full sources)
12. PURENESS.ZIP....1st place megademo during 'The Scene 95' demo party at
Seaview Hotel/Singapore on 2nd July 1995.
13. COROMSRC.ZIP....Source codes to a BBS advert
14. WATERFAL.ZIP....Source codes to a waterfall effect as seen in REXINTRO.
............................Year 1996......................................
15. PLASWARP.ZIP....Source codes to the plasma and image warp effect as
seen in Pureness (needs PURENESS.DAT to run)
16. DEVSITE!.ZIP....BBS advert for Developer's Site BBS, now WaterLogic's
HQ. Features SVGA 3D motion blur.
16. AGEN-ART.ZIP....High-res JPGs of Agen's art seen in Pureness
17. STARGATE.ZIP....Source codes to the texture-mapped wormhole seen
in Pureness.
18. MODELIST.ZIP....Generic VESA graphic mode lister with sources in C
19. VOXELSPC.ZIP....Source codes to a Voxel landscape with color and height-
field interpolation
20. DEVSITE2.ZIP....Part 2 of the 'infamous' DevSite! BBS HQ advert
(coming soon to a BBS near you)
21. D???????.ZIP....Megademo for 'The Scene 96'!
(Sense and Sensuality, needs ice to run)
*/
// VOXEL-SPACE SYSTEM BY -=REX DEATHSTAR=- March 1995
// Version V9 : Further optimizations
#pragma inline
asm .486p
#include <math.h>
#include <process.h>
#include <dos.h>
#include <stdio.h>
void graphics();
void text();
void vretrace();
void load_voxeldata();
void rotate_frame();
void load_heightfield();
void draw_scape2();
void perspective();
void bankpitch();
void smooth_mesh();
void smooth_cmap();
void move_light_source();
void shade_grid();
void gouraud_shade();
void post_process();
#define rad 0.01745329
#define MAX_YAW 720
#define YAW_RES 360.0/MAX_YAW*rad
#define NPOLYROWS 40
//#define DYNAMIC 1
//#define REAL_LIGHT 1
#define dToR(d) ((d)*(M_PI/180))
#define pixelScale 63.0
//----- GENERAL PURPOSE --------
char palette[1024];
int a,x,y,dummy;
unsigned int idx,idx2,idx3;
long nframes;
//-------------------------------
//---- VIEW POINT ORIENTATION -----
int bank,bank_dir=0;
int yaw,yaw_dir=1;
long tx,ty;
long tx_dir=260,ty_dir=256;
// |
float p1x=-40,p1y=NPOLYROWS; // 1-----------2
float p2x=40,p2y=NPOLYROWS; // \ | /
float p4x=-5,p3y=0; // \ | /
float p3x=5,p4y=0; //_____4-----3_____
//---------------------------------- |
// ^origin
//------- GRID CONSTRUCTION --------
int vcx,vcy,vcz;
long sx,sy,fx,fy,sx2,sy2,fx2,fy2;
long ix,iy;
long esx,esy;
long efx,efy,err1,err2;
int slope;
//----------------------------------
//------ G-SHADED POLYGON ---------------------------------
int xx1,yy1,yy3,y11,y12,y13,y21,y22,y23,y31,y32,y33;
char color1,color2,color3,color4;
unsigned int eyy1,eyy2,fyy1,fyy2,temp,b;
int ecolorx1,ecolorx2,ecolory,fcolorx1,fcolorx2,fcolory;
//---------------------------------------------------------
//------- GRID CORNER LOOK-UP TABLE --------
long sine,cosine;
long x1,y1,x2,y2,x3,y3,x4,y4; //coords of 4 corners of trapezium
//-------------------------------------------
//------- REAL-TIME G-SHADING -----------
long Lx,Ly,Lz;
float azimuth=dToR(0),azimuth_dir=0.05;
float elevation=dToR(30),elevation_dir=0;
long Nx,Ny,Nz,Nz2,NzLz,NdotL;
int brightness;
//---------------------------------------
//-------------- SEGMENT DATA --------------------------
unsigned int voxeldata,colormap,voxel,vbuffer;
unsigned int y_offset[204],jmptable[200];
char cmap[NPOLYROWS*81],color;
//------------------------------------------------------
asm voxelfile db 'height.dat',0
asm colorfile db 'color.dat',0
asm palettefile db 'voxelspc.pal',0
//---------------------------------------------------------------------------
void main()
{
if(allocmem(1024,&voxel)!=-1) exit(1);
if(allocmem(4096,&voxeldata)!=-1) exit(1);
if(allocmem(4096,&vbuffer)!=-1) exit(1);
if(allocmem(4096,&colormap)!=-1) exit(1);
asm mov [dummy],offset one_vert_strip
for(a=0; a<200; a++)
jmptable[a]=dummy+(200*6)-(a*6);
graphics();
load_voxeldata();
post_process();
{
MAIN_LOOP:;
rotate_frame(); //rotate 4 corners of landscape
load_heightfield(); //read elevation data from voxeldata
perspective();
draw_scape2(); //draw to screen
nframes++;
}
asm in al,60h
asm cmp al,1
asm jne MAIN_LOOP
text();
printf("No.of frames drawn:%d",nframes);
}
//------------------
void perspective()
{
asm mov es,voxel
asm xor di,di
asm mov si,280 //altitude of view
asm mov ax,es:[2* ((NPOLYROWS-1)*81+40) ]
asm sub si,ax
asm sub si,128
#define PERSPECTIV 1000
// ax = bp*(height+elevation)/(z+256)
asm mov slope,-NPOLYROWS/2
asm mov bp,600
asm mov bx,PERSPECTIV
asm add bx,256 // bx => z in equation
outer_loop:
asm mov cx,81
do_perspective:
asm mov ax,es:[di] //...'y', height info
asm add ax,si
asm imul bp // y' = -y*d / (z+d)
asm idiv bx
asm mov es:[di],ax
asm add di,2
asm dec cx
asm jnz do_perspective
asm sub bx,(PERSPECTIV/NPOLYROWS)
asm cmp bx,256
asm jg outer_loop
//bankpitch();
#ifdef REAL_LIGHT
shade_grid();
#endif
smooth_mesh();
smooth_cmap();
}
//-------------------------------------------------------------------------
void load_heightfield()
{
//move an area of shape trapezius containing height data into voxel buffer
asm mov gs,[colormap]
asm mov fs,[voxeldata]
asm mov es,[voxel]
//THE FOLLOWING DEFINES THE 4 CORNERS OF THE TRAPEZIUM
sx=x1; sy=y1; //start point //top-left
fx=x2; fy=y2; //end point //top-rite
sx2=x4; sy2=y4; //bot-left
fx2=x3; fy2=y3; //bot_rite
//-----------------------------------------------------
//FIND ERROR TERM FOR 2 DIAGONAL SIDES OF THE TRAPEZIUM
esx=(sx2-sx)/NPOLYROWS;
esy=(sy2-sy)/NPOLYROWS;
efx=(fx2-fx)/NPOLYROWS;
efy=(fy2-fy)/NPOLYROWS; //to be donein NPOLYROWS steps
//-----------------------------------------------------
//vcx,vcz are voxel x,z co-ord counters
//x,z used becoz of orientation of grid plane
asm xor di,di //voxel[] offset counter
asm xor si,si //cmap[] offset counter
idx=0;
for(vcz=0; vcz<NPOLYROWS; vcz++)// define y start-end of grid
{
ix=sx;
iy=sy;
//err1=(fx-sx)/80; //error term for current
//err2=(fy-sy)/80; //scanline IN trapezium
asm mov esi,81
asm mov eax,dword ptr [fx]
asm sub eax,dword ptr [sx]
asm cdq
asm idiv esi
asm mov dword ptr err1,eax
asm mov eax,dword ptr fy
asm sub eax,dword ptr sy
asm cdq
asm idiv esi
asm mov dword ptr err2,eax
//define x start-end of grid, eg 0..320, step=4
asm mov cx,81
vcx_loop:
asm mov ebx,dword ptr iy
//asm shr ebx,8 // remove fix-point
//asm shl ebx,8 // mul by 256, map width in bytes
asm xor bl,bl
asm mov eax,dword ptr ix
asm shr eax,8 // remove fix-point
asm add ebx,eax //offset in voxeldata and colormap
asm xor ax,ax
asm mov al,fs:[bx]
asm stosw //save height info
asm mov si,idx
asm mov al,gs:[bx]
asm mov cmap[si],al
asm inc idx
ix+=err1; //update pointer of scanline
iy+=err2;
asm dec cx
asm jnz vcx_loop
sx+=esx; //update start point
sy+=esy;
fx+=efx; //update end point
fy+=efy;
}
}
//-------------------------------------------------------------------------
void draw_scape2()
{
asm mov es,[voxel]
asm mov fs,[voxel]
asm mov di,offset 81*(NPOLYROWS-2)*2
asm mov ax,200
asm mov cx,81*2
asm rep stosw
asm xor si,si
asm mov cx,NPOLYROWS*81
clip_loop:
asm mov ax,fs:[si]
asm cmp ax,200
asm jl less
asm mov ax,200
asm jmp done_clip
less:
asm cmp ax,0
asm jg more
asm xor ax,ax
more:
done_clip:
asm mov fs:[si],ax
asm add si,2
asm dec cx
asm jnz clip_loop
//CLEAR VIRTUAL BUFFER
asm mov es,[vbuffer]
asm xor eax,eax
asm xor di,di
asm mov cx,200*320/4
asm rep stosd
asm mov si,81*5*2
//asm xor si,si
asm mov bx,offset cmap+(81*5)
//DRAW THE WHOLE VOXEL
asm mov cx,NPOLYROWS-6 //1st 5 lines invisible due
outer_loop: //to perspective
asm bswap ecx
asm xor cx,cx
inner_loop:
//fyy1=yy1*256; //top start at left
//fyy2=yy3*256; //bot start at left
//eyy1=256*(yy2-yy1)/4; //error term for top side of poly
//eyy2=256*(yy4-yy3)/4; //error term for bot side of poly
asm mov eax,fs:[si] //get y coord
asm mov dx,ax //yy1
asm mov [fyy1+1],ax //fyy1=ax<<8
asm shr eax,16 //yy2
asm sub ax,dx
asm shl ax,8-2
asm mov [eyy1],ax
asm mov eax,fs:[si+81*2]
asm mov dx,ax //yy3
asm mov [fyy2+1],ax //fyy2=ax<<8
asm shr eax,16 //yy4
asm sub ax,dx
asm shl ax,8-2
asm mov [eyy2],ax
asm mov [xx1],cx
asm push si
asm push ecx
asm push bx
//DON'T DESTROY BX B4 THIS!
//fcolorx1=color1<<8;
//fcolorx2=color3<<8;
asm mov cx,[bx] // cx=color1,2
asm mov dx,[bx+81] // dx=color3,4
asm xor ax,ax // 1----2 <- colors 1,2,3,4
asm mov ah,cl // | |
asm mov si,ax // 3----4
asm mov ah,dl // si=fcolorx1,bp=fcolorx2 are used to
asm mov bp,ax // compute color err.term in y-dir
//ecolorx1=256*(color2-color1)/4; //color err.term in x-dir
//ecolorx2=256*(color4-color3)/4; //across the polygon
asm sub ch,cl
asm sub dh,dl
asm sar cx,2
asm sar dx,2
asm mov [ecolorx1],cx
asm mov [ecolorx2],dx
//|||||||||||||||||||||||||||||||||||||||||||
//||| regs used: si=fcolorx1, bp=fcolorx2 |||
//|||||||||||||||||||||||||||||||||||||||||||
asm mov [a],4
do_one_polygon:
//compute color error term in y-direction for current vert.strip
//b=(fyy2-fyy1)/128;
asm mov cx,[fyy2]
asm sub cx,[fyy1] // get length of current strip
asm jns visible // if pos+, current strip visible
asm jmp stripskipper // else hidden, so skip
visible:
asm shr cx,8
asm jz b_is_zero // if cx=0, avoid int0
asm mov ax,bp // ax=fcolorx2-fcolorx1
asm sub ax,si
asm cwd
asm idiv cx // ax = ecolory = dx:ax/cx
b_is_zero:
// ax,cx must be preserved from here on
asm xor bx,bx
asm mov bl,byte ptr [fyy1+1] // start at top of current strip
asm add bx,bx // word array,after removing fix-pt
asm mov dx,320 // screen width in bytes
asm mov di,y_offset[bx]
asm add di,[xx1] // start offset
asm mov bx,cx // bx=length of current strip
asm mov cx,si // cx=fcolorx1
//|||| DO ONE VERTICAL STRIP ||||
asm push ds
asm add bx,bx
asm mov bx,jmptable[bx]
asm mov ds,[vbuffer]
asm jmp bx
asm one_vert_strip: // fill one vertical strip
asm rept 201 // always draw one extra pixel
asm mov [di],ch // draw pixel
asm add di,dx // next scanline
asm add cx,ax // fcolory+=ecolory
asm endm
asm pop ds
//||||||||||||||||||||||||||||||||
stripskipper:
xx1++; //move on to next vertical strip
fyy1+=eyy1; //update top side of polygon
fyy2+=eyy2; //update bot side of polygon
asm add si,[ecolorx1] //fcolorx1+=ecolorx1, color at top of strip
asm add bp,[ecolorx2] //fcolorx2+=ecolorx2, color at bottom of strip
asm dec [a]
asm jz done_one_polygon
asm jmp do_one_polygon
done_one_polygon:
asm pop bx
asm pop ecx
asm pop si
skipper:
asm add si,2
asm inc bx
asm add cx,4
asm cmp cx,320
asm jge next_poly_row
asm jmp inner_loop
next_poly_row:
asm bswap ecx
asm add si,2
asm inc bx
asm dec cx
asm jz draw_done
asm jmp outer_loop
draw_done:
//copy to VRAM
vretrace();
asm mov ax,0a000h
asm mov es,ax
asm xor di,di
asm xor si,si
asm push ds
asm mov ds,vbuffer
asm mov cx,200*320/4
asm rep movsd
asm pop ds
}
//------------------------------------------
void shade_grid()
{
Nz = (6 * 64) / 6;
Nz2 = Nz * Nz;
NzLz = Nz * Lz;
asm mov fs,voxel
asm mov si,81*2
asm xor si,si
asm mov idx,0
//DRAW THE WHOLE VOXEL
asm mov cx,81*NPOLYROWS-(81)
shadeit:
asm mov ax,fs:[si-2-81*2]
asm mov y11,ax
asm mov ax,fs:[si-81*2]
asm mov y12,ax
asm mov ax,fs:[si+2-81*2]
asm mov y13,ax
asm mov ax,fs:[si-2]
asm mov y21,ax
asm mov ax,fs:[si]
asm mov y22,ax
asm mov ax,fs:[si+2]
asm mov y23,ax
asm mov ax,fs:[si-2+81*2]
asm mov y31,ax
asm mov ax,fs:[si+81*2]
asm mov y32,ax
asm mov ax,fs:[si+2+81*2]
asm mov y33,ax
asm push si
asm push cx
gouraud_shade();
asm pop cx
asm pop si
skipper:
asm add si,2
asm inc idx
asm dec cx
asm jz shade_done
asm jmp shadeit
shade_done:;
move_light_source();
}
//-------------------------------------------
void gouraud_shade()
{
Nx = (int)(y11 + y21 + y31 - y13 - y23 - y33);
Ny = (int)(y31 + y32 + y33 - y11 - y12 - y13);
/* shade with distant light source */
if ( (NdotL = Nx*Lx + Ny*Ly + NzLz) < 0 )
brightness = 0;
else
brightness = NdotL / sqrt(Nx*Nx + Ny*Ny + Nz2);
cmap[idx]=brightness;
}
//------------------------------
void move_light_source()
{
Lx = cos(azimuth) * cos(elevation) * pixelScale;
Ly = sin(azimuth) * cos(elevation) * pixelScale;
Lz = sin(elevation) * pixelScale;
azimuth+=azimuth_dir;
elevation+=elevation_dir;
}
//----------------------------
void smooth_mesh()
{
asm mov es,voxel
asm xor di,di
asm mov dx,NPOLYROWS
outer:
asm mov cx,80
meow:
asm mov ax,es:[di]
asm add ax,es:[di+2]
asm shr ax,1
asm mov es:[di],ax
asm add di,2
asm dec cx
asm jnz meow
asm add di,2
asm dec dx
asm jnz outer
}
//-----------------------
void smooth_cmap()
{
asm {
mov cx,NPOLYROWS*81
mov di,offset cmap+81
xor bx,bx
}
interpolate_cmap:
asm {
xor ax,ax
mov al,[di]
mov bl,[di-1]
add ax,bx
mov bl,[di+1]
add ax,bx
mov bl,[di+81]
add ax,bx
mov bl,[di+82]
add ax,bx
mov bl,[di+80]
add ax,bx
mov bl,[di-81]
add ax,bx
mov bl,[di-80]
add ax,bx
shr ax,3
mov [di],al
inc di
dec cx
jnz interpolate_cmap
}
}
//------------------------------------------------------------------------
void rotate_frame()
{
x1 = 256*( p1x*cos(YAW_RES*yaw) + p1y*sin(YAW_RES*yaw) )+tx;
y1 = 256*( p1y*cos(YAW_RES*yaw) - p1x*sin(YAW_RES*yaw) )+ty;
x2 = 256*( p2x*cos(YAW_RES*yaw) + p2y*sin(YAW_RES*yaw) )+tx;
y2 = 256*( p2y*cos(YAW_RES*yaw) - p2x*sin(YAW_RES*yaw) )+ty;
x3 = 256*( p3x*cos(YAW_RES*yaw) + p3y*sin(YAW_RES*yaw) )+tx;
y3 = 256*( p3y*cos(YAW_RES*yaw) - p3x*sin(YAW_RES*yaw) )+ty;
x4 = 256*( p4x*cos(YAW_RES*yaw) + p4y*sin(YAW_RES*yaw) )+tx;
y4 = 256*( p4y*cos(YAW_RES*yaw) - p4x*sin(YAW_RES*yaw) )+ty;
yaw+=yaw_dir;
if(yaw<0) yaw=MAX_YAW;
else
if(yaw>MAX_YAW) yaw=0;
#ifndef DYNAMIC
tx+=tx_dir;
ty+=ty_dir;
#else
tx=300*sin(0.7*tx_dir*rad); tx_dir++;
ty=128*cos(ty_dir*rad); ty_dir++;
#endif
}
//------------------------------------------------------------------------
void load_voxeldata()
{
//LOAD VOXEL DATA
asm mov ax,3d00h
asm mov dx,offset voxelfile
asm int 21h
asm mov dummy,ax
asm mov bp,2 //no.of 32Kb segments
asm xor dx,dx
load_loop:
asm mov bx,dummy //load 32Kb
asm mov cx,0x8000
asm mov ah,3fh
asm push ds
asm mov ds,voxeldata
asm int 21h
asm pop ds
asm add dx,0x8000
asm dec bp
asm jnz load_loop
asm mov bx,dummy
asm mov ah,3eh
asm int 21h
//LOAD COLOR DATA
asm mov ax,3d00h
asm mov dx,offset colorfile
asm int 21h
asm mov dummy,ax
asm mov bp,2 //no.of 32Kb segments
asm xor dx,dx
load_loop2:
asm mov bx,dummy //load 32Kb
asm mov cx,0x8000
asm mov ah,3fh
asm push ds
asm mov ds,[colormap]
asm int 21h
asm pop ds
asm add dx,0x8000
asm dec bp
asm jnz load_loop2
asm mov bx,dummy
asm mov ah,3eh
asm int 21h
asm mov ax,0x3d00
asm mov dx,offset palettefile
asm int 0x21
asm mov bx,ax
asm mov cx,768
asm mov ah,0x3f
asm lea dx,[palette]
asm int 0x21
asm mov bx,dummy
asm mov ah,0x3e
asm int 0x21
asm mov dx,0x3c8
asm xor ax,ax
asm out dx,al
asm inc dx
asm mov cx,768
asm lea si,[palette]
asm cld
asm rep outsb
}
//------------------------------------------
void graphics()
{
for(a=0; a<204; a++)
y_offset[a]=a*320;
asm mov ax,13h
asm int 10h
}
//-----------------
void text()
{
asm mov ax,3
asm int 10h
}
//------------------
void vretrace()
{
asm mov dx,3dah
vr1:
asm in al,dx
asm test al,8
asm jz vr1
vr2:
asm in al,dx
asm test al,8
asm jnz vr2
}
//---------------------
void bankpitch()
{
//DO BANKING : Z-axis rotation
sine=1024*sin(bank*rad);
cosine=1024*cos(bank*rad);
asm mov es,voxel
asm xor di,di
asm mov cx,NPOLYROWS
outer_loop:
asm mov edx,-160
loop3D_Z:
asm mov ebx,edx
asm imul ebx,dword ptr sine
asm movsx eax,word ptr es:[di]
asm imul eax,dword ptr cosine
asm sub eax,ebx
asm shr eax,10
asm stosw
asm add edx,4
asm cmp edx,160
asm jle loop3D_Z
asm dec cx
asm jnz outer_loop
bank+=bank_dir;
if(bank<=-15 || bank>=15) bank_dir*=-1;
}
//-------------------
void post_process()
{
asm mov es,voxeldata
asm xor di,di
asm mov bx,5
smoothen:
asm xor ax,ax
asm mov al,es:[di]
asm add al,es:[di-1]
asm adc ah,0
asm add al,es:[di+1]
asm adc ah,0
asm add al,es:[di-256]
asm adc ah,0
asm add al,es:[di+256]
asm adc ah,0
asm div bl
asm mov es:[di],al
asm inc di
asm jnz smoothen
/*move_light_source();
Nz = (6 * pixelScale) / 6;
Nz2 = Nz * Nz;
NzLz = Nz * Lz;
asm mov idx,0
asm mov es,colormap
asm mov fs,voxeldata
asm xor si,si
process_loop:
asm xor ax,ax
asm mov al,fs:[si-256-1]
asm mov y11,ax
asm mov al,fs:[si-256]
asm mov y12,ax
asm mov al,fs:[si-256+1]
asm mov y13,ax
asm mov al,fs:[si-1]
asm mov y21,ax
asm mov al,fs:[si]
asm mov y22,ax
asm mov al,fs:[si+1]
asm mov y23,ax
asm mov al,fs:[si+256-1]
asm mov y31,ax
asm mov al,fs:[si+256]
asm mov y32,ax
asm mov al,fs:[si+256+1]
asm mov y33,ax
asm pusha
gouraud_shade();
asm popa
asm mov al,cmap[0]
asm mov es:[si],al
asm inc si
asm jnz process_loop*/
}